var height = $(document.body).height()+"px";
var factoryData = [];
var roleData = [];
//用react封装
var currentpage = 1,totlepage = 1,i;//分页的当前页和总的页数
//表单数据
var tableData = [];
//表单的最高高度、当前第几页、总页数、总行数
var otherData = {maxHeight:'0px',currentpage:0,totlepage:0,totlerows:0,pageLeft:0,pageRight:0};
//分页
var Page = React.createClass({
    setPage: function (e) {
        setPage($(e.target).html());
        this.props.onPageClick(1);
    },
    showPage: function () {
        showPage();
    },
    render: function () {
        {
            var items = [],
                svar = this;
            if(totlepage == 0){
                items.push({num:1,checked:true})
            }else if(totlepage < 6){
                for(i = 1;i <= totlepage ;i++) {
                    if (i == currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
            }else if(currentpage >= (totlepage-2)) {//点在左边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                for(i = totlepage-1;i <= totlepage ;i++){
                    if(i == currentpage){
                        items.push({num:i,checked:true})
                    }else{
                        items.push({num:i,checked:false})
                    }
                }
            }else if(currentpage <= 3){
                for(i = 1;i <= 3 ;i++) {
                    if (i == currentpage) {
                        items.push({num:i,checked:true})
                    } else {
                        items.push({num:i,checked:false})
                    }
                }
                items.push({num:'···',checked:false});
                items.push({num:totlepage,checked:false})
            }else {//点在两边
                items.push({num:1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:currentpage-1,checked:false});
                items.push({num:currentpage,checked:true});
                items.push({num:currentpage+1,checked:false});
                items.push({num:'···',checked:false});
                items.push({num:totlepage,checked:false})
            }
        }
        return (
            <div className="tableInfo-page">
                <div className="page-number">每页<span  className="page-number-list" onClick={this.showPage}>{pagecount}</span>条</div>
                <div className="page-list" style={{top:pageListTop+"px"}}>
                    <ul>
                        {
                            pageList.map(function (item) {
                                return (<li onClick={svar.setPage}>{item}</li>)
                            })
                        }
                    </ul>
                </div>
                <div className="page-limit">
                    <ol className="page-limit-ol">
                        <ol className="page-limit-ol">
                            <li className="page-limit-img" name="-1" onClick={otherData.pageLeft == 0?'':svar.props.onPageClick.bind(svar,-1)}><span className={otherData.pageLeft == 0?'page-limit-left-no':'page-limit-left-yes'}/></li>
                            {
                                items.map(function (item) {
                                    return (<li onClick={isNaN(item.num)?'':svar.props.onPageClick.bind(svar,item.num)} className={item.checked == true?'page-limit-num page-limit-checked':'page-limit-num'} name={item.num}>{item.num}</li>)
                                })
                            }
                            <li className="page-limit-img" name="-2" onClick={otherData.pageRight == 0?'':svar.props.onPageClick.bind(svar,-2)}><span className={otherData.pageRight == 0?'page-limit-right-no':'page-limit-right-yes'}/></li>
                        </ol>
                    </ol>
                </div>
            </div>
        );
    }
});
//表单组件
var Table = React.createClass({
    render: function () {
        return (
            <tr>
                <td style={{width: '10%'}}>{parseInt(this.props.listNumber)+1}</td>
                <td style={{width: '10%'}}>{this.props.queryresultaccount}</td>
                <td style={{width: '10%'}}>{this.props.queryresultuserName}</td>
                <td style={{width: '15%'}}>{this.props.queryresultorganName}</td>
                <td style={{width: '10%'}}>{this.props.queryresulttel}</td>
                <td style={{width: '10%'}}>{this.props.queryresultstatus==null?"":(this.props.queryresultstatus=="1"?"正常":(this.props.queryresultstatus=="2"?"已停用":(this.props.queryresultstatus=="-1"?"已删除":"")))}</td>
                <td style={{width: '10%'}}>{this.props.queryresultlastLoginTimeString}</td>
                <td style={{width: '10%'}}>{this.props.lastLoginIp}</td>
                <td style={{width: '20%'}}>
                    {("1"==this.props.queryresultstatus || "2"==this.props.queryresultstatus)?<div className="trButton trLeft table-select" onClick={this.props.onClickUpdateShow}>修改</div>:""}
                    {("1"==this.props.queryresultstatus || "2"==this.props.queryresultstatus)?<div className="trButton trLeft userDelete" onClick={this.props.onClickDelete}>删除</div>:""}
                    {"1"==this.props.queryresultstatus?<div className="trButton trLeft table-delete" onClick={this.props.onClickStop}>停用</div>:""}
                    {"2"==this.props.queryresultstatus?<div className="trButton trLeft" onClick={this.props.onClickStart}>启用</div>:""}
                    <div className="trButton trLeft" onClick={this.props.onClickResetPassword}>重置</div>
                </td>
            </tr>
        );
    }
});
//组织组件
var Organ = React.createClass({
    render: function () {
        return (
            <span className="gl-two" data-id={""+this.props.id}  data-name={""+this.props.name} data-prefix={""+this.props.prefix} data-remark={""+this.props.remark}>
                {this.props.name}
            </span>
        );
    }
});
//父组件
var Main = React.createClass({
    //组件初始状态
    getInitialState: function () {
        return {
            otherData:this.props.otherData,
            tableData:this.props.tableData,
            factoryData:this.props.factoryData,
            roleData:this.props.roleData,
            addresData:[],
            schoolDataAll:[],//所有学校
            schoolLeftData:[],//弹出层左侧数据
            schoolRightData:[],//弹出层右侧数据
            isSale:false,//所属机构是否是销售部
            isSaleManager:false,//是否是销售部管理员

        }
    },
    componentDidMount: function () {
        //查询用户列表
        var svar = this;
        suixun.ajax(serverUrl+'/userManager/queryUser.json','param={num:"'+pagecount+'"}',"get",function(data){
            if(data.list != null){
                for(var i=0;i<data.list.length;i++){
                    var obj=data.list[i];
                    tableData[i] = {notAdmin:data.notAdmin,queryresultid:obj.id,lastLoginIp:obj.lastLoginIp,queryresultaccount:obj.account,queryresultuserName:obj.userName,queryresultorganName:obj.organName,queryresulttel:obj.tel,queryresultlastLoginTimeString:obj.lastLoginTimeString,queryresultorganId:obj.organId,queryresultworkNumber:obj.workNumber,queryresultstatus:obj.status};
                }
                var pageRight = 0;
                if(data.totalpage > 1){
                    pageRight = 1
                }
                otherData = {maxHeight:height,currentpage:1,totlepage:data.totalpage,totlerows:data.totalNum,pageLeft:0,pageRight:pageRight};
                currentpage = 1;totlepage = data.totalpage;//初始化的时候赋值：分页的当前页和总的页数
                svar.setState({tableData:tableData,otherData:otherData,factoryData:factoryData,roleData:roleData});
            }
        });
        //查询组织列表
        suixun.ajax(serverUrl+'/organManager/queryOrgan.json','',"get",function(data){
            if(data != null){
                for(var i=0;i<data.length;i++){
                    var obj=data[i];
                    if(i == 0){
                        factoryData[i] = {id:obj.id,name:obj.name,prefix:obj.prefix,remark:obj.remark,selected:'selected'};
                        if(obj.name == '销售部'){
                            svar.setState({isSale:true});
                        }
                        continue;
                    }
                    factoryData[i] = {id:obj.id,name:obj.name,prefix:obj.prefix,remark:obj.remark,selected:''};
                }
                svar.setState({tableData:tableData,otherData:otherData,factoryData:factoryData});
            }
        });
        //查询角色类型
        suixun.ajax(serverUrl+'/roleManager/listRole.json','',"get",function(data){
            setTimeout(function () {
                suixun.hideLoding();//隐藏加载中
            },500);
            if(data.code == 200){
                for(var i=0;i<data.info.list.length;i++){
                    var obj=data.info.list[i];
                    roleData[i] = {id:obj.id,name:obj.name};
                }
                svar.setState({roleData:roleData});
            }
        });
        suixun.ajax(serverUrl+'/schoolManage/querySchool.json','',"get",function(data){
            if(data.code == 200 && data.info != null){
                var schoolDataList = [];
                for(var i=0;i<data.info.length;i++){
                    var obj=data.info[i];
                    schoolDataList[i] = {key:i,id:obj.id,schoolname:obj.schoolname,province:obj.province,city:obj.city,town:obj.town};
                }
                svar.setState({schoolDataAll:schoolDataList});
            }else{
                svar.setState({schoolDataAll:[]});
            }
        });
        svar.selectAddress();
        //绑定回车时间
        $(document).keypress(function(e) {
            var eCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
            if (eCode == 13){
                if($(".enterEvent").is(":focus")){
                    svar.onClickQuery();
                }
            }
        });
    },
    /**
     * 查询
     *
     */
    onClickQuery: function () {
        var searchName = $("#searchName").val();
        var searchType = $(".school-or-table").html();
        var param ="param={";
        if(searchType=="手机号"){
            if(searchName.length > 0){
                if(!/^[1-9]\d*$/.test(searchName)){
                    suixun.alert("手机号格式错误!");
                    return;
                }
            }
            param = getJsonDataNotEmpty(param,"tel",""+searchName+"");
        }else{
            param = getJsonDataNotEmpty(param,"userName",""+searchName+"");
        }
        param = getJsonDataNotEmpty(param,"num",pagecount+'');
        param += "}";
        tableData=[];
        suixun.showLoding();//显示加载中
        var svar = this;
        suixun.ajax(serverUrl+'/userManager/queryUser.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.list != null){
                for(var i=0;i<data.list.length;i++){
                    var obj=data.list[i];
                    tableData[i] = {notAdmin:data.notAdmin,queryresultid:obj.id,lastLoginIp:obj.lastLoginIp,queryresultaccount:obj.account,queryresultuserName:obj.userName,queryresultorganName:obj.organName,queryresulttel:obj.tel,queryresultlastLoginTimeString:obj.lastLoginTimeString,queryresultorganId:obj.organId,queryresultworkNumber:obj.workNumber,queryresultstatus:obj.status};
                }
                otherData = {maxHeight:height,currentpage:1,totlepage:1,totlerows:data.totalNum,pageLeft:0,pageRight:0};
                currentpage = 1;totlepage = 1;//初始化的时候赋值：分页的当前页和总的页数
                svar.setState({tableData:tableData,otherData:otherData});
            }
        });
    },
    /**
     * 分页
     * @param num 当前页码
     */
    onPageClick: function (num) {
        //分页-调用ajac然后把数据查询出来:获取name的值
        //计算currentpage
        suixun.showLoding();//显示加载中
        var onPageLeft = 0,onPageRight = 1,svar = this;
        if(num > 0){
            currentpage = num;
        }else if(num == -1 && currentpage > 1){
            currentpage --;
        }else if(num == -2  && currentpage < totlepage){
            currentpage ++;
        }
        //修改左右的按钮
        if((currentpage == totlepage && totlepage == 1)|| totlepage == 0){
            onPageLeft = 0;
            onPageRight = 0;
        }else if(currentpage == totlepage && totlepage > 1){
            onPageLeft = 1;
            onPageRight = 0;
        }else if(1 < currentpage && currentpage < totlepage){
            onPageLeft = 1;onPageRight = 1;
        }
        //执行ajax获取数据然后组装
        var searchName = $("#searchName").val();
        var searchType = $(".school-or-table").html();
        var param ="param={";
        param = getJsonDataNotEmpty(param,"index",'"'+currentpage+'"');
        if(searchName != ""){
            if(searchType=="手机号"){
                param = getJsonDataNotEmpty(param,"tel",'"'+searchName+'"');
            }else{
                param = getJsonDataNotEmpty(param,"userName",'"'+searchName+'"');
            }
        }
        param = getJsonDataNotEmpty(param,"num",pagecount+'');
        param += "}";
        tableData = [];
        suixun.ajax(serverUrl+'/userManager/queryUser.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.list != null){
                for(var i=0;i<data.list.length;i++){
                    var obj=data.list[i];
                    tableData[i] = {notAdmin:data.notAdmin,queryresultid:obj.id,lastLoginIp:obj.lastLoginIp,queryresultaccount:obj.account,queryresultuserName:obj.userName,queryresultorganName:obj.organName,queryresulttel:obj.tel,queryresultlastLoginTimeString:obj.lastLoginTimeString,queryresultorganId:obj.organId,queryresultworkNumber:obj.workNumber,queryresultstatus:obj.status};
                }
                if(data.totalpage > 1 && data.totalpage > currentpage){
                    onPageRight = 1;
                }else{
                    onPageRight = 0;
                }
                otherData = {maxHeight:height,currentpage:currentpage,totlepage:data.totalpage,totlerows:data.totalNum,pageLeft:onPageLeft,pageRight:onPageRight};
                totlepage = data.totalpage;//初始化的时候赋值：分页的当前页和总的页数
                svar.setState({tableData:tableData,otherData:otherData});
            }
        });
    },
    /**
     * 修改、保存账户
     */
    onClockUpdate: function () {
        var organId=$("#organId").val(),userName=$("#userName").val(),workNumber=$("#workNumber").val(),tel=$("#tel").val();
        if(organId == null){
            suixun.alert("请选择机构!");
            return;
        }
        if(workNumber == ""){
            suixun.alert("用户工号不能为空!");
            $(".upUserId-error").show();
            return;
        }else{
            $(".upUserId-error").hide();
        }
        if(userName == ""){
            suixun.alert("账户名称不能为空!");
            $(".upUserName-error").show();
            return;
        }else{
            $(".upUserName-error").hide();
        }
        if(tel == ""){
            suixun.alert("手机号码不能为空!");
            $(".upUserPhone-error").show();
            return;
        }else if(tel.length != 11){
            suixun.alert("手机号码格式错误!");
            $(".upUserPhone-error").show();
            return;
        }else if(!/^[^\u4e00-\u9fa5]{0,}$/.test(tel)){
            $("#tel").val("");
            suixun.alert("手机号码格式错误!");
            $(".upUserPhone-error").show();
            return;
        }else{
            $(".upUserPhone-error").hide();
        }
        var svar = this;
        var schoolids = '';
        for(var j=0;j<svar.state.schoolRightData.length;j++){
            schoolids += svar.state.schoolRightData[j].id+"|";
        }
        if(schoolids.indexOf('|') > 0){
            schoolids = schoolids.substring(0,schoolids.length-1);
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"id",$("#updateUserId").val()+'');
        param = getJsonDataNotEmpty(param,"organId",$("#organId").val());
        param = getJsonDataNotEmpty(param,"userName",$("#userName").val());
        param = getJsonDataNotEmpty(param,"workNumber",$("#workNumber").val());
        param = getJsonDataNotEmpty(param,"tel",$("#tel").val());
        param = getJsonDataNotEmpty(param,"schoolid",'"'+schoolids+'"');
        param = getJsonDataNotEmpty(param,"roleIdList",$("#roleId option:selected").val()+'');
        param += "}";
        suixun.showLoding();//显示加载中
        if($(".table-form-title").html()=='修改账户信息'){
            suixun.ajax(serverUrl+'/userManager/updateUser.json',param,"get",function(data){
                suixun.hideLoding(200);//隐藏加载中
                if(data.code == 200){
                    suixun.alert("修改成功！",function (data) {
                        if(data){
                            svar.onClickHidePop();
                            svar.onPageClick(currentpage);
                            svar.setState({schoolRightData:[],schoolLeftData:[]});
                        }
                    });
                } else {
                    suixun.alert(data.msg);
                }
            });
        }else{
            suixun.ajax(serverUrl+'/userManager/addUser.json',param,"get",function(data){
                suixun.hideLoding(200);//隐藏加载中
                if(data.code == 200){
                    suixun.alert("新增成功!",function (data) {
                        if(data){
                            svar.onClickHidePop();
                            svar.onPageClick(currentpage);
                        }
                    });
                } else {
                    suixun.alert(data.msg);
                }
            });
        }

    },
    /**
     * 点击table删除按钮
     * @param info
     * @returns {boolean}
     */
    onClickDelete: function (info) {
        if(info==null || info.length<2 || info[0]==null || info[0]==""){
            suixun.alert("参数错误");
            return false;
        }
        var svar = this;
        suixun.confirm_noTit("你确定要删除用户 "+info[1]+" 吗？",function (data) {
            if(data == true){
                suixun.showLoding();//显示加载中
                var id=info[0];
                var param="param={";
                param = getJsonDataNotEmpty(param,"id",id+"");
                param += "}";
                suixun.ajax(serverUrl+'/userManager/deleteUser.json',param,"get",function(data){
                    suixun.hideLoding(200);//隐藏加载中
                    if(data.code == 200){
                        suixun.alert("删除成功",function (data) {
                            if(data){
                                svar.onClickHidePop();
                                var tbodyData = $("#tbodyData").children();
                                if(tbodyData.length == 1 && currentpage > 1){
                                    totlepage = totlepage - 1;
                                    svar.onPageClick(currentpage-1);//更新数据
                                }else{
                                    svar.onPageClick(currentpage);//更新数据
                                }
                            }
                        });
                    }else{
                        suixun.alert(data.msg);
                    }
                });
            }
        });
    },
    /**
     * 点击table停用用户按钮
     * @param info
     * @returns {boolean}
     */
    onClickStop: function (info) {
        if(info==null || info.length<2 || info[0]==null || info[0]==""){
            suixun.alert("参数错误");
            return false;
        }
        var svar = this;
        suixun.confirm_noTit("你确定要停用用户 "+info[1]+" 吗？",function (data) {
            if(data == true){
                suixun.showLoding();//显示加载中
                var id=info[0];
                var param="param={";
                param = getJsonDataNotEmpty(param,"id",id+"");
                param = getJsonDataNotEmpty(param,"status","2");
                param += "}";
                suixun.ajax(serverUrl+'/userManager/updateUser.json',param,"get",function(data){
                    suixun.hideLoding(200);//隐藏加载中
                    if(data.code == 200){
                        suixun.alert("停用成功",function (data) {
                            if(data){
                                svar.onClickHidePop();
                                svar.onPageClick(currentpage);
                            }
                        });
                    } else {
                        suixun.alert(data.msg);
                    }
                });
            }
        });
    },
    /**
     * 点击table启用按钮
     * @param info
     * @returns {boolean}
     */
    onClickStart: function (info) {
        if(info==null || info.length<2 || info[0]==null || info[0]==""){
            suixun.alert("参数错误");
            return false;
        }
        var svar = this;
        suixun.confirm_noTit("你确定要启用用户 "+info[1]+" 吗？",function (data) {
            if(data == true){
                suixun.showLoding();//显示加载中
                var id=info[0];
                var param="param={";
                param = getJsonDataNotEmpty(param,"id",id+"");
                param = getJsonDataNotEmpty(param,"status","1");
                param += "}";
                $.ajax({
                    url:serverUrl+'/userManager/updateUser.json',
                    data:param,
                    dataType:'json',
                    success:function (data) {
                        suixun.hideLoding(200);//隐藏加载中
                        if(data.code == 200){
                            suixun.alert("启用成功",function (data) {
                                if(data){
                                    svar.onClickHidePop();
                                    svar.onPageClick(currentpage);
                                }
                            });
                        } else {
                            suixun.alert(data.msg);
                        }
                    }.bind(this),
                    error: function (req,info,error) {
                        top.location.href = invalidUrl;
                    }
                });
            }
        });
    },
    /**
     * 重置密码
     * @param id
     */
    onClickResetPassword: function (id) {
        suixun.confirm_noTit("是否确定重置密码？",function (data) {
            if(data) {
                suixun.showLoding();//显示加载中
                var param="param={";
                param = getJsonDataNotEmpty(param,"id",id+'');
                param += "}";
                suixun.ajax(serverUrl+'/userManager/resetPassword.json',param,'get',function (data) {
                    suixun.hideLoding();//关闭加载中
                    if(data.code == 200){
                        suixun.alert('重置密码成功！');
                    }else{
                        suixun.alert(data.msg);
                    }
                });
            }
        });
    },
    /**
     * 显示修改界面
     * @param info
     */
    onClickUpdateShow: function (info) {
        suixun.showLoding();//显示加载中
        var id = info[0],
            notAdmin = info[1],
            svar = this;
        var param="param={";
        param = getJsonDataNotEmpty(param,"id",id+'');
        param += "}";
        suixun.ajax(serverUrl+'/userManager/getUser.json',param,'get',function (data) {
            if(data.code == 200){
                var obj = data.info;
                $("#updateUserId").val(id);//
                $("#userName").val(obj.userName);//
                $("#workNumber").val(obj.workNumber);//
                $("#organId").val(obj.organId);//
                if(obj.roleList != null && obj.roleList.length > 0){
                    $("#roleId").val(obj.roleList[0].id);//
                }else{
                    $("#roleId").val('');
                }
                $("#tel").val(obj.tel);//
                $(".table-form-title").html("修改账户信息");
                if(notAdmin){
                    if(info[2] == '销售部'){
                        svar.setState({isSale:true,isSaleManager:true});
                    }else{
                        svar.setState({isSale:false,isSaleManager:true});
                    }
                }else{
                    svar.setState({isSale:true,isSaleManager:false});
                }
                if(info[2] == '销售部'){
                    if(obj.schoolList != null){
                        var schoolList = obj.schoolList,schoolRightData = [];
                        for(var i = 0;i < schoolList.length;i++){
                            var obj = schoolList[i];
                            schoolRightData[i] = {key:i,id:obj.id,schoolname:obj.schoolname,province:obj.province,city:obj.city,town:obj.town};
                        }
                        svar.setState({schoolRightData:schoolRightData});
                    }
                }
                $(".popPhone[data-index=1]").show();
                suixun.hideLoding();//显示加载中
            }else{
                suixun.hideLoding();//显示加载中
            }
        });
    },
    /**
     * 关闭修改pop
     */
    onClickHidePop: function () {
        $(".popPhone").hide();
        $(".errorMsg").hide();
        this.onClickCloseInput();
    },
    /**
     * 点击组织
     * @param info
     * @returns {boolean}
     */
    onClickOrgan: function (info) {
        if(info==null || info.length<1 || info[0]==null || info[0]==""){
            return false;
        }
        suixun.showLoding();//显示加载中
        var param="param={";
        param = getJsonDataNotEmpty(param,"organId",info[0]+"");
        param = getJsonDataNotEmpty(param,"num",pagecount+'');
        param += "}";
        tableData=[];
        var svar = this;
        suixun.ajax(serverUrl+'/userManager/queryUser.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.list != null){
                for(var i=0;i<data.list.length;i++){
                    var obj=data.list[i];
                    tableData[i] = {notAdmin:data.notAdmin,queryresultid:obj.id,lastLoginIp:obj.lastLoginIp,queryresultaccount:obj.account,queryresultuserName:obj.userName,queryresultorganName:obj.organName,queryresulttel:obj.tel,queryresultlastLoginTimeString:obj.lastLoginTimeString,queryresultorganId:obj.organId,queryresultworkNumber:obj.workNumber,queryresultstatus:obj.status};
                }
                otherData = {maxHeight:height,currentpage:1,totlepage:data.totalpage,totlerows:data.totalNum,pageLeft:0,pageRight:1};
                currentpage = 1;totlepage = data.totalpage;//初始化的时候赋值：分页的当前页和总的页数
                svar.setState({tableData:tableData,otherData:otherData,factoryData:factoryData});
            }
        });
    },
    /**
     * 新增或修改组织
     */
    onClockUpdateOrgan: function () {
        if($("#name").val() == ""){
            suixun.alert("组织名称不能为空!");
            $(".name-error").show();
            return;
        }
        if($("#prefix").val() == ""){
            suixun.alert("组织前缀不能为空!");
            $(".prefix-error").show();
            return;
        }
        suixun.showLoding();//显示加载中
        var param="param={";
        param = getJsonDataNotEmpty(param,"id",$("#organ_Id").val());
        param = getJsonDataNotEmpty(param,"prefix",$("#prefix").val());
        param = getJsonDataNotEmpty(param,"remark",$("#remark").val());
        param = getJsonDataNotEmpty(param,"name",$("#name").val());
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/organManager/updateOrOrgan.json',param,"get",function(data){
            suixun.hideLoding(200);//隐藏加载中
            if(data.code == 200){
                suixun.alert("保存成功",function (data) {
                    if(data){
                        suixun.showLoding();//显示加载中
                        if($("#organ_Id").val() != ""){
                            svar.onPageClick(currentpage);
                        }
                        svar.onClickHidePop();
                        $.ajax({
                            url:serverUrl+'/organManager/queryOrgan.json',
                            dataType:'json',
                            success:function (data) {
                                suixun.hideLoding(200);//隐藏加载中
                                if(data != null){
                                    factoryData = [];
                                    for(var i=0;i<data.length;i++){
                                        var obj=data[i];
                                        factoryData[i] = {id:obj.id,name:obj.name,prefix:obj.prefix,remark:obj.remark};
                                    }
                                    svar.setState({factoryData:factoryData});
                                }

                            }.bind(this)
                        });
                    }
                });
            } else {
                suixun.alert(data.msg);
            }
        });
    },
    /**
     * 编辑组织管理
     * @param info
     */
    onClickEditOrgan: function (info) {
        $("#organ_Id").val(info[0]);//
        $("#name").val(info[1]);//
        $("#prefix").val(info[2]);//
        $("#remark").val(info[3]);//
        $(".organ-form-title").html("编辑组织管理");
        $(".popPhone[data-index=2]").show();
    },
    /**
     * 添加分组
     */
    onClickAddGroup: function () {
        this.onClickGlTwoAdd();
    },
    /**
     * 添加账户
     */
    onClickAddUser: function () {
        $("#updateUserId").val("");//
        $("#userName").val("");//
        $("#workNumber").val("");//
        $("#organId").val("");//
        $("#tel").val("");//
        $("#roleId").val("");
        $(".table-form-title").html("新增账户信息");
        this.setState({isSale:false,isSaleManager:false});
        $(".popPhone[data-index=1]").show();
    },
    /**
     * 验证
     * @param e
     */
    onBlurInput: function (e) {
        var classname = e.target.getAttribute("data-error");
        if($(e.target).val() == ''){
            $("."+classname+"").show();
        }else{
            $("."+classname+"").hide();
        }
    },
    /**
     * 添加分组
     */
    onClickGlTwoAdd: function () {
        $(".popPhone[data-index=2]").show();
        $("#name").val("");
        $("#prefix").val("");
        $("#remark").val("");
        $("#organ_Id").val("")
        $("#gl-two-id").val("");
        $(".organ-form-title").html("添加组织");
    },
    /**
     * 修改分组
     */
    onClickGlTwoUpdate: function () {
        $(".popPhone[data-index=2]").show();
        $("#name").val($("#gl-two-name").val());
        $("#prefix").val($("#gl-two-prefix").val());
        $("#remark").val( $("#gl-two-remark").val());
        $("#gl-two-id").val($("#gl-two-id").attr("data-id"));
        $(".organ-form-title").html("修改组织");
    },
    /**
     * 删除分组
     */
    onClickGlTwoDelete: function () {
        var name = $("#name").val();
        var id = $("#organ_Id").val();
        var svar = this;
        suixun.confirm_noTit("你确定要删除名称为 "+name+" 的组织吗？",function (data) {
            if(data){
                suixun.showLoding();//显示加载中
                var param ="param={";
                param = getJsonDataNotEmpty(param,"id",id+"");
                param += "}";
                suixun.ajax(serverUrl+'/organManager/deleteAuthOrganByIds.json',param,"get",function(data){
                    suixun.hideLoding(200);//隐藏加载中
                    if(data.code == 200){
                        suixun.alert("删除成功",function (data) {
                            if(data){
                                suixun.showLoding();//显示加载中
                                svar.onClickHidePop();
                                $.ajax({
                                    url:serverUrl+'/organManager/queryOrgan.json',
                                    dataType:'json',
                                    success:function (data) {
                                        factoryData = [];
                                        suixun.hideLoding(200);//隐藏加载中
                                        if(data != null){
                                            for(var i=0;i<data.length;i++){
                                                var obj=data[i];
                                                factoryData[i] = {id:obj.id,name:obj.name,prefix:obj.prefix,remark:obj.remark};
                                            }
                                            svar.setState({factoryData:factoryData});
                                        }else{
                                            svar.setState({factoryData:factoryData});
                                        }
                                    }.bind(this)
                                });
                            }
                        });
                    } else {
                        suixun.alert(data.msg+"!");
                    }
                });
            }
        });
    },
    /**
     * addresData
     * 查询地址-省份
     */
    selectAddress:function () {
        var svar = this;
        var param="param={";
        param = getJsonDataNotEmpty(param,"type","1");
        param += "}";
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            if(data.code == 200){
                let addresData=[];
                for(let i = 0 ;i < data.info.length;i++ ){
                    addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                }
                svar.setState({addresData:addresData});
            }
        });
    },
    /**
     * 清空地区并隐藏地区
     *  然后去调用分页
     * @returns {XML}
     */
    onClickCloseInput: function () {
        $("#recyleReserveAddress").val("");
        $(".addressesOne").hide();
        $(".address-closeMsg").hide();
        $(".province").addClass(" addresses-select cli");
        $(".city").removeClass("cli addresses-select");
        $(".area").removeClass(" cli addresses-select");
        $('.parentCheckBox').attr('checked',false);
        // this.setState({schoolRightData:[],schoolLeftData:[]});
        this.setState({schoolLeftData:[]});
        this.selectAddress();
    },
    /**
     * 查询地址
     * @param e
     */
    queryAddress:function (e) {
        var type = $(e.target).attr("data-type"),
            province = $(e.target).attr("data-province"),
            city = $(e.target).attr("data-city");
        if(type == "1"){
            $("#recyleReserveAddress").val(province);
            $("#recyleReserveAddress").attr("title",province);
            $(".province").removeClass(" addresses-select");
            $(".province").addClass(" cli");
            $(".city").addClass(" addresses-select");
            $(".area").removeClass(" cli");
            $(".address-closeMsg").show();//显示关闭按钮
            this.onClickQuerySchoolList();//查询学校
        }else if(type == "2"){
            $("#recyleReserveAddress").val(province+"-"+city);
            $("#recyleReserveAddress").attr("title",province + "-" + city );
            $(".city").removeClass(" addresses-select");
            $(".city").addClass(" cli");
            $(".area").addClass(" addresses-select");
            $(".address-closeMsg").show();//显示关闭按钮
            this.onClickQuerySchoolList();//查询学校
        }else {
            $("#recyleReserveAddress").val(province + "-" + city + "-" + e.target.innerHTML);
            $("#recyleReserveAddress").attr("title",province + "-" + city + "-" + e.target.innerHTML);
            $(".addressesOne").hide();
            $(".address-closeMsg").show();//显示关闭按钮
            this.onClickQuerySchoolList();//查询学校
            return;
        }
        type = parseInt(type)+1;
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+type+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            let addresData = [];
            if(data.code == 200){
                if(type == "1"){
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                    }
                }else if(type == "2"){
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].city,type:"2",city:data.info[i].city,province:province};
                    }
                }else{
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].town,type:"3",city:city,province:province};
                    }
                }
            }
            svar.setState({addresData:addresData});

        });
    },
    /**
     * 点击城市
     * @param e
     */
    onClickCity: function (e) {
        var type = $(e.target).attr("data-type"),addres = $("#recyleReserveAddress").val(),addreses = addres.split("-"),province = "",city = "";
        if(addres == "选择省市区"){
            return;
        }
        if(type == "1"){
            province = "";
            city = "";
        }else if(type == "2"){
            if(addreses[0] != ""){
                province = addreses[0];
                city = "";
            }else{
                return;
            }
        }else if(type == "3"){
            if(addreses[0] != "" && addreses.length > 1){
                province = addreses[0];
                city = addreses[1];
            }else{
                return;
            }
        }else if(type == "4"){
            $(".addressesOne").hide();
            return;
        }
        $(e.target).addClass(" addresses-select").siblings().removeClass(" addresses-select");
        if(addreses[0] != "" && addreses.length == 1){
            $(".city").addClass("cli");
            $(".province").addClass("cli");
            $(".area").removeClass(" cli");
        }else if(addreses.length == 2 || addreses.length == 3){
            $(".city").addClass("cli");
            $(".province").addClass("cli");
            $(".area").addClass(" cli");
        }else{
            $(".city").removeClass("cli");
            $(".area").removeClass(" cli");
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"type",'"'+type+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param += "}";
        var svar = this;
        suixun.ajax(serverUrl+'/schoolManage/queryRegion.json',param,"get",function(data){
            let addresData = [];
            if(data.code == 200){
                if(type == "1"){
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].province,type:"1",province:data.info[i].province,city:""};
                    }
                }else if(type == "2"){
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].city,type:"2",city:data.info[i].city,province:province};
                    }
                }else{
                    for(let i = 0 ;i < data.info.length;i++ ){
                        addresData[i] = {value:data.info[i].town,type:"3",city:city,province:province};
                    }
                }
            }
            svar.setState({addresData:addresData});
        });
    },
    /**
     * 点击选择地区
     * @returns {XML}
     */
    onClickAddressSelect: function () {
        if($(".addressesOne").is(":hidden")){
            $(".addressesOne").show();
        }else{
            $(".addressesOne").hide();
        }
    },
    /**
     * 查询学校列表
     * @returns {XML}
     */
    onClickQuerySchoolList: function () {
        var svar = this,schoolname = $("#schoolname_search").val(),address = $("#recyleReserveAddress").val(),province = "",city = "",town = "";
        if(address == ""){
            suixun.alert("请选择地区！");
            return;
        }else if(address.indexOf("-") > 0){
            var value = address.split("-");
            if(value.length == 2){
                province = value[0];
                city = value[1];
            }else{
                province = value[0];
                city = value[1];
                town = value[2];
            }
        }else{
            province = address;
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"schoolname",'"'+schoolname+'"');
        param = getJsonDataNotEmpty(param,"province",'"'+province+'"');
        param = getJsonDataNotEmpty(param,"city",'"'+city+'"');
        param = getJsonDataNotEmpty(param,"town",'"'+town+'"');
        param += "}";
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/schoolManage/querySchool.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            var schoolData = [];
            if(data.code == 200 ){
                for(var i=0;i<data.info.length;i++){
                    var obj=data.info[i],b = false;
                    for(var j=0;j<svar.state.schoolRightData.length;j++){
                       if(obj.id == svar.state.schoolRightData[j].id){
                           b = true;
                           break;
                       }
                    }
                    if(b){
                        schoolData[i] = {key:i,id:obj.id,schoolname:obj.schoolname,province:obj.province,city:obj.city,town:obj.town,checked:'checked'};
                    }else{
                        schoolData[i] = {key:i,id:obj.id,schoolname:obj.schoolname,province:obj.province,city:obj.city,town:obj.town,checked:''};
                    }
                }
                svar.setState({schoolLeftData:schoolData});
                svar.clickChecked();
            }else{
                svar.setState({schoolLeftData:[]});
            }
        });
    },
    /**
     * 点击全部
     */
    onclickCheckboxAll: function(e){
        var svar = this,schoolData = [];
        if($(e.target).is(":checked")){
            for(var i=0;i<svar.state.schoolLeftData.length;i++){
                var obj=svar.state.schoolLeftData[i],b = false;
                svar.state.schoolLeftData[i].checked = 'checked';
                for(var j=0;j<svar.state.schoolRightData.length;j++){
                    if(obj.id == svar.state.schoolRightData[j].id){
                        b = true;
                        break;
                    }
                }
                if(!b){
                    svar.state.schoolRightData.push({key:j,id:obj.id,schoolname:obj.schoolname,province:obj.province,city:obj.city,town:obj.town});
                }
                schoolData[i] = {key:i,id:obj.id,schoolname:obj.schoolname,province:obj.province,city:obj.city,town:obj.town,checked:'checked'};
            }
        }else{
            for(var i=0;i<svar.state.schoolLeftData.length;i++){
                var obj=svar.state.schoolLeftData[i],b = false;
                svar.state.schoolLeftData[i].checked = 'checked';
                for(var j=0;j<svar.state.schoolRightData.length;j++){
                    if(obj.id == svar.state.schoolRightData[j].id){
                        b = true;
                        svar.state.schoolRightData.splice(j,1);
                        break;
                    }
                }
                schoolData[i] = {key:i,id:obj.id,schoolname:obj.schoolname,province:obj.province,city:obj.city,town:obj.town,checked:''};
            }
        }
        svar.setState({schoolLeftData:schoolData,schoolRightData:svar.state.schoolRightData});
    },
    /**
     * 弹出层-选中学校
     * @returns {XML}
     */
    onclickCheckbox: function (e) {
        var id = $(e.target).attr('data-id'),svar = this,b = true;
        var schoolName = $(e.target).attr('data-school');
        var schoolRightData = svar.state.schoolRightData,schoolRightDataT = [];
        if($(e.target).is(":checked")){
            for(var j=0;j<svar.state.schoolRightData.length;j++){
                var obj = svar.state.schoolRightData[j];
                if(id == obj.id){
                    b = false;
                    break;
                }
            }
            for(var i=0;i<svar.state.schoolLeftData.length;i++){
                var obj=svar.state.schoolLeftData[i];
                if(obj.id == id){
                    svar.state.schoolLeftData[i].checked = 'checked';
                    if(b){
                        schoolRightData.push({key:schoolRightData.length,id:id,schoolname:schoolName,province:obj.province,city:obj.city,town:obj.town});
                        svar.setState({schoolRightData:schoolRightData});
                    }
                    break;
                }
            }
        }else{
            var i = 0;
            for(var j=0;j<svar.state.schoolRightData.length;j++){
                var obj = svar.state.schoolRightData[j];
                if(id != obj.id){
                    schoolRightDataT[i] = {key:j,id:obj.id,schoolname:obj.schoolname,province:obj.province,city:obj.city,town:obj.town};
                    i++;
                }
            }
            for(var i=0;i<svar.state.schoolLeftData.length;i++){
                var obj=svar.state.schoolLeftData[i];
                if(obj.id == id){
                    svar.state.schoolLeftData[i].checked = '';
                    break;
                }
            }
            svar.setState({schoolRightData:schoolRightDataT});
            $(e.target).attr('checked',false);
        }
        svar.setState({schoolLeftData:svar.state.schoolLeftData});
        svar.clickChecked();
    },
    /**
     * 弹出层-删除学校
     * @returns {XML}
     */
    onclickReduceSchool: function (e) {
        var id = $(e.target).attr('data-id'),svar = this;
        var schoolRightDataT = [];
        var i = 0;
        for(var j=0;j<svar.state.schoolRightData.length;j++){
            var obj = svar.state.schoolRightData[j];
            if(id != obj.id){
                schoolRightDataT[i] = {key:j,id:obj.id,schoolname:obj.schoolname,province:obj.province,city:obj.city,town:obj.town};
                i++;
            }
        }
        for(var i=0;i<svar.state.schoolLeftData.length;i++){
            var obj=svar.state.schoolLeftData[i];
            if(obj.id == id){
                svar.state.schoolLeftData[i].checked = '';
                break;
            }
        }
        svar.setState({schoolRightData:schoolRightDataT,schoolLeftData:svar.state.schoolLeftData});
        if(svar.state.schoolLeftData.length != 0){
            svar.clickChecked();
        }
    },
    /**
     * 是否选中全部
     * @returns {XML}
     */
    clickChecked: function () {
        var svar = this;
        var b = 0;
        if(svar.state.schoolLeftData.length == 0){
            return;
        }
        for(var i=0;i<svar.state.schoolLeftData.length;i++){
            var obj=svar.state.schoolLeftData[i];
            if(obj.checked == 'checked'){
                b ++;
            }
        }
        if(b == svar.state.schoolLeftData.length){
            $('.parentCheckBox').prop('checked',true);
        }else{
            $('.parentCheckBox').attr('checked',false);
        }
    },
    /**
     * 改变所属机构
     * @returns {XML}
     */
    onChangeOrgan: function(){
        if($("#organId option:selected").text() == '销售部'){
            this.setState({schoolLeftData:[],schoolRightData:[]});
            this.setState({isSale:true});
        }else{
            this.setState({isSale:false});
        }
        var param="param={";
        param = getJsonDataNotEmpty(param,"organId",'"'+$("#organId option:selected").val()+'"');
        param += "}";
        suixun.showLoding();//显示加载中
        suixun.ajax(serverUrl+'/userManager/getNewWorkNumber.json',param,"get",function(data){
            suixun.hideLoding();//隐藏加载中
            if(data.code == 200 ){
                $("#workNumber").val(data.info.newWorkNumber);
            }
        });
    },
    render: function () {
        {
            var svar = this;
            var onClickArray = [this.onClickUpdateShow,this.onClickDelete,this.onClickStop,this.onClickStart,this.onClickOrgan,this.onClickEditOrgan,this.onClickResetPassword];//,this.resetPassword
            var Tabels = this.state.tableData.map(function (data,index) {
                return (
                    <Table key={data.queryresultid} lastLoginIp={data.lastLoginIp} listNumber={index}  queryresultaccount={data.queryresultaccount} queryresultuserName={data.queryresultuserName} queryresultorganName={data.queryresultorganName} queryresulttel={data.queryresulttel} queryresultlastLoginTimeString={data.queryresultlastLoginTimeString} queryresultstatus={data.queryresultstatus}  onClickUpdateShow={onClickArray[0].bind(svar,[data.queryresultid,data.notAdmin,data.queryresultorganName])} onClickResetPassword={onClickArray[6].bind(svar,[data.queryresultid])} onClickDelete={onClickArray[1].bind(svar,[data.queryresultid,data.queryresultuserName])} onClickStop={onClickArray[2].bind(svar,[data.queryresultid,data.queryresultuserName])} onClickStart={onClickArray[3].bind(svar,[data.queryresultid,data.queryresultuserName])}/>//resetPassword={onClickArray[8].bind(svar,[data.queryresultid,data.queryresultuserName])}
                )
            });
            var Organs = factoryData.map(function (data) {
                return (
                    <Organ key={data.id}  name={data.name} remark={data.remark} id={data.id} prefix={data.prefix}  onClickOrgan={onClickArray[4].bind(svar,[data.id])} onClickEditOrgan={onClickArray[5].bind(svar,[data.id,data.name,data.prefix,data.remark])}   />
                )
            });
        }
        return (
            <div className="tableManage-body">
                <div  className="popPhone popModel " data-index="1">
                    <input type="hidden" name="id" id="updateUserId" />
                    <div className="model"></div>
                    <div className={svar.state.isSale == false?'popModel-info popUser-info updateUserInfo':'popModel-info popUser-info updateUserInfo updateUserInfoSale'}>
                        <div className="popModel-title">
                            <span className="popModel-title-content">
                                <span className="popModel-title-content-solid-left" style={{width:"125px"}}/>
                                <span className="table-form-title">修改账户信息</span>
                                <span className="popModel-title-content-solid-right" style={{width:"125px"}}/>
                            </span>
                            <span className="popModel-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                        </div>
                        <div className="popModel-body">
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">所属机构</span>
                                <span className="popModel-body-input-content" >
                                    <select  name="organId" id="organId" data-dataType="Number" placeholder="请选择机构" onChange={this.onChangeOrgan} >
                                        {
                                            factoryData.map(function (data) {
                                                return (
                                                    <option value={data.id} selected={data.selected}>{data.name}</option>
                                                )
                                            })
                                        }
                                    </select>
                                </span>
                                {
                                    svar.state.isSaleManager == false?''
                                        :
                                        <div className="noClickModel noClickModelSize"></div>
                                }
                            </div>
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">所属角色</span>
                                <span className="popModel-body-input-content" >
                                    <select  name="roleId" id="roleId" placeholder="请选择角色" >
                                        {
                                            roleData.map(function (data) {
                                                return (
                                                    <option value={data.id} >{data.name}</option>
                                                )
                                            })
                                        }
                                    </select>
                                </span>
                                {
                                    svar.state.isSaleManager == false?''
                                        :
                                        <div className="noClickModel noClickModelSize"></div>
                                }
                            </div>
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">用户工号</span>
                                <span className="popModel-body-input-content">
                                    <input className="input-content" type="text" readOnly="readOnly" onBlur={this.onBlurInput} data-error="upUserId-error" name="workNumber" maxLength="20"  id="workNumber" placeholder="请输入用户工号"/>
                                </span>
                                <div className="errorMsg upUserId-error" style={{marginRight:'210px'}} ></div>
                                {
                                    svar.state.isSaleManager == false?''
                                        :
                                        <div className="noClickModel noClickModelSize"></div>
                                }
                            </div>

                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">账户名称</span>
                                <span className="popModel-body-input-content">
                                    <input className="input-content" type="text" name="userName" onBlur={this.onBlurInput} data-error="upUserName-error" maxLength="20"  id="userName" placeholder="请输入账户名称" />
                                </span>
                                <div className="errorMsg upUserName-error" style={{marginRight:'210px'}} ></div>
                                {
                                    svar.state.isSaleManager == false?''
                                        :
                                        <div className="noClickModel noClickModelSize"></div>
                                }
                            </div>
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">手机号码</span>
                                <span className="popModel-body-input-content">
                                    <input className="input-content" type="text" name="tel" onBlur={this.onBlurInput} data-error="upUserPhone-error" maxLength="11" id="tel" placeholder="请输入手机号码" />
                                </span>
                                <div className="errorMsg upUserPhone-error" style={{marginRight:'210px'}} ></div>
                                {
                                    svar.state.isSaleManager == false?''
                                        :
                                        <div className="noClickModel noClickModelSize"></div>
                                }
                            </div>
                            {
                                svar.state.isSale == false?''
                                    :
                                    <div>
                                        <div className="popModel-body-input">
                                            <span className="popModel-body-input-title" style={{backgroundImage: "url()"}}>选择地区</span>
                                            <span className="popModel-body-input-content" style={{width: "300px"}} >
                                            <input className="input-content " id="recyleReserveAddress" title="" style={{width:"280px"}} onClick={this.onClickAddressSelect} readOnly="readOnly" type="text" placeholder="选择省市区"  />
                                            <span className="closeMsg address-closeMsg" onClick={this.onClickCloseInput} />
                                             <div className="queryMsg address-aueryMsg" onClick={this.onClickQuerySchoolList} ></div>
                                            <div className="addresses addressesOne" >
                                                <div className="addresses-title">
                                                    <ul className="city-tab">
                                                        <li className="city-tab-list province addresses-select cli" onClick={this.onClickCity} data-type="1">省 份</li>
                                                        <li className="city-tab-list city" onClick={this.onClickCity} data-type="2">城 市</li>
                                                        <li className="city-tab-list area" onClick={this.onClickCity} data-type="3">区（县）</li>
                                                    </ul>
                                                </div>
                                                <div className="addresses-content">
                                                    <ul className="addresses-content-item">
                                                        {
                                                            svar.state.addresData.map(function(data){
                                                                return(
                                                                    <li onClick={svar.queryAddress} data-type={data.type} data-province={data.province} data-city={data.city} title={data.value} className="addresses-item-center text-sub">{data.value}</li>
                                                                )
                                                            })
                                                        }
                                                    </ul>
                                                </div>
                                            </div>
                                        </span>
                                        </div>
                                        <div className="popModel-body-input">
                                            <span className="popModel-body-input-title" style={{backgroundImage: "url()"}}>搜索学校</span>
                                            <span className="popModel-body-input-content" style={{width: "300px"}}>
                                                <input className="queryVal enterEvent input-content" type="text" style={{width: "260px"}} data-list="schoolname_search"  name="schoolname_search" id="schoolname_search" maxLength="50" placeholder="搜索学校"/>
                                            </span>
                                            <div className="queryMsg" onClick={this.onClickQuerySchoolList}></div>
                                        </div>
                                        <div className="popModel-body-divContainer">
                                            <div className="container-left">
                                                <span className="container-left-title"><input className="parentCheckBox" type="checkbox" onClick={svar.onclickCheckboxAll} />全部</span>
                                                <ul className="container-left-ul">
                                                    {
                                                        svar.state.schoolLeftData.map(function(data){
                                                            return(
                                                                <li><input  className="childCheckBox" id={"checkBoxChild"+data.id} type="checkbox" data-id={data.id} data-school={data.schoolname} checked={data.checked} onClick={svar.onclickCheckbox} />{data.schoolname}</li>
                                                            )
                                                        })
                                                    }
                                                </ul>
                                            </div>
                                            <div className="container-right">
                                                <span className="container-right-title">已选择学校</span>
                                                <ul>
                                                    {
                                                        svar.state.schoolRightData.map(function(data){
                                                            return(
                                                                <li title={data.schoolname}><img className="reduceImg" src="../img/icon/reduce.png" data-id={data.id} data-school={data.schoolname} onClick={svar.onclickReduceSchool} />{data.schoolname}&nbsp;&nbsp;&nbsp;&nbsp;{data.province}{data.city}{data.town}</li>
                                                            )
                                                        })
                                                    }
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                            }
                        </div>
                        <div className="popModel-button">
                            <span className="popModel-button-ok" onClick={this.onClockUpdate}>确定</span>
                        </div>
                    </div>
                </div>

                <div className="popPhone group-two popModel" data-index="2">
                    <input type="hidden" name="organ_Id" id="organ_Id" value=""/>
                    <div className="model"></div>
                    <div className="popPhone-info popUser-info group-two-info popModel-info">
                        <div className="popModel-title">
                            <span className="popModel-title-content">
                                <span className="popModel-title-content-solid-left" style={{width:"90px"}}/>
                                <span className="organ-form-title">修改组织信息</span>
                                <span className="popModel-title-content-solid-right" style={{width:"90px"}}/>
                            </span>
                            <span className="popModel-title-img" onClick={this.onClickHidePop}><img src="../img/icon/close.png" alt="关闭"/></span>
                        </div>
                        <div className="popModel-body">
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">组织名称</span>
                                <span className="popModel-body-input-content">
                                    <input className="input-content" type="text" name="name" id="name" onBlur={this.onBlurInput} data-error="name-error" maxLength="20" placeholder="请输入组织名称"  />
                                </span>
                                <div className="errorMsg name-error"></div>
                            </div>
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title">组织前缀</span>
                                <span className="popModel-body-input-content">
                                    <input className="input-content" type="text" name="prefix" id="prefix" onBlur={this.onBlurInput} data-error="prefix-error" maxLength="20" placeholder="请输入组织前缀" />
                                </span>
                                <div className="errorMsg prefix-error"></div>
                            </div>
                            <div className="popModel-body-input">
                                <span className="popModel-body-input-title" style={{background:"url()"}}>备注</span>
                                <span className="popModel-body-input-content">
                                    <input className="input-content" type="text" name="remark" id="remark" maxLength="50" placeholder="组织备注" />
                                </span>
                            </div>
                        </div>
                        <div className="popModel-button">
                            <span className="popModel-button-ok" onClick={this.onClockUpdateOrgan}>确定</span>
                        </div>
                    </div>
                </div>

                <div className="button-group-f-div clearfix">
                    <span className="button-group-span-all">组织管理</span>
                    <div className="button-group clearfix" onClick={this.onClickAddGroup}>
                        <img src="../img/icon/add-white.png" />
                        <span>添加部门</span>
                    </div>
                </div>
                <div className="griopList clearfix">
                    {Organs}
                    <span className="gl-two-button griopList-two-add" onClick={this.onClickGlTwoAdd}>添加</span>
                    <span className="gl-two-button griopList-two-update" onClick={this.onClickGlTwoUpdate}>修改</span>
                    <span className="gl-two-button griopList-two-delete" onClick={this.onClickGlTwoDelete}>删除</span>
                    <input type="hidden" id="gl-two-id"/>
                    <input type="hidden" id="gl-two-name"/>
                    <input type="hidden" id="gl-two-prefix"/>
                    <input type="hidden" id="gl-two-remark"/>
                </div>
                <div className="tableTop">
                    <div className="tableTop-left">
                        账户列表
                    </div>
                    <div className="tableTop-right">
                        <div className="tableTop-right-f-div">
                            <div className="tableTop-right-select droup-select">
                                <div className="school-or-parent school-or-table" >姓名</div>
                                <span className="lower-right-corner"/>
                                <div className="drop-down">
                                    <span className="select-value school-name" data-value="1">姓名</span>
                                    <span className="select-value parent-name" data-value="2">手机号</span>
                                </div>
                            </div>
                            <div className="tableTop-right-query">
                                <div className="tableTop-right-query-input">
                                    <input className="queryVal enterEvent" type="text" id="searchName" name="searchName" maxLength="20" placeholder="请输入姓名搜索"/>
                                </div>
                                <div className="tableTop-right-query-img" onClick={this.onClickQuery}></div>
                            </div>
                        </div>
                        <div className="tableTop-right-addUser" onClick={this.onClickAddUser}>
                            <img src="../img/icon/add-white.png" />
                            <span>添加账户</span>
                        </div>
                    </div>
                </div>
                <div className="tableInfo">
                    <div className="tableInfo-data">
                        <div className="tableInfo-data-table" >
                            <table className="head-body">
                                <thead>
                                    <th style={{width: '10%'}}>序号</th>
                                    <th style={{width: '10%'}}>账号</th>
                                    <th style={{width: '10%'}}>姓名</th>
                                    <th style={{width: '15%'}}>组织</th>
                                    <th style={{width: '10%'}}>手机号</th>
                                    <th style={{width: '10%'}}>状态</th>
                                    <th style={{width: '10%'}}>最后登录时间</th>
                                    <th style={{width: '10%'}}>最后登录IP</th>
                                    <th style={{width: '20%'}}>操作</th>
                                </thead>
                                <tbody id="tbodyData">
                                    {this.state.tableData==""?'':Tabels}
                                </tbody>
                            </table>
                            {this.state.tableData==""?<div className="tableNoData">{tableNoDataCount}</div>:''}
                        </div>
                    </div>
                    <Page maxHeight={this.state.maxHeight} pageLeft={this.state.pageLeft} onPageRight={this.state.onPageRight} currentpage={this.state.currentpage} totlepage={this.state.totlepage} totlerows={this.state.totlerows} onPageClick={this.onPageClick} />
                </div>
                <footer id="copyright">
                    <span><img src="../img/icon/copyright.png"/>{copyright}</span>
                </footer>
            </div>
        );
    }
});
ReactDOM.render(
    <Main  otherData={otherData} tableData={tableData} />,
    document.getElementById('tableManage')
);
//点击下拉框
$(".tableTop-right-select").click(function () {
    if($(".drop-down").is(":hidden")){
        $('.drop-down').slideDown();
    }else{
        $('.drop-down').slideUp();
    }
});
//选择姓名、手机号码
$('.drop-down > span').click(function() {
    $('#searchType').val($(this).attr("data-value"));
    if($(this).html() == "姓名" && $(".school-or-table").html() != "姓名"){
        $(".queryVal").attr("placeholder","请输入姓名搜索").attr("maxLength","20").val("");
        $("#searchName").val("");
    }else if($(this).html() == "手机号" && $(".school-or-table").html() != "手机号"){
        $(".queryVal").attr("placeholder","请输入手机号搜索").attr("maxLength","11").val("");
        $("#searchName").val("");
    }
    $(".school-or-table").html($(this).html());
    $('.drop-down').slideUp();
});
//新增组织
$('.header-left-new').click(function() {
    $("#organ_Id").val("");//
    $("#name").val("");//
    $("#prefix").val("");//
    $("#remark").val("");//
    $(".organ-form-title").html("新增组织管理");
    $(".popPhone[data-index=2]").show();
});
var type = true;
$(".griopList").on("mousemove",".gl-two",function () {
    $(".gl-two-button").show();
});
$(".griopList").on("mouseout",".gl-two",function () {
    if(type){
        $(".gl-two-button").hide();
    }
});
//监听全局点击事件
$("*").bind("click",function(e){
    var target=$(e.target);
    if(!$(".group-two > .model").is(":hidden")){
        return;
    }
    if(target.closest(".gl-two-button").length == 1){
        return;
    }
    if(target.closest(".gl-two").length == 1){
        $(".gl-two-button").show();
        type = false;
        $("#gl-two-id").val($(target).attr("data-id"));
        $("#organ_Id").val($(target).attr("data-id"));
        $("#gl-two-name").val($(target).attr("data-name"));
        $("#gl-two-prefix").val($(target).attr("data-prefix"));
        if($(target).attr("data-remark") == "null"){
            $("#gl-two-remark").val("");
        }else{
            $("#gl-two-remark").val($(target).attr("data-remark"));
        }
        $(".gl-two").removeClass(" gl-two-select");
        $(target).addClass(" gl-two-select");
    }else{
        $(".gl-two-button").hide();
        type = true;
        $(".gl-two").removeClass(" gl-two-select");
    }
    //弹出层
    if(target.closest(".city-tab-list").length == 1 || target.closest(".addresses-item-center").length == 1 || target.closest(".addresses-content").length == 1 ){

    }else{
        $(".addressesOne").hide();
    }
});
/**
 * 删除学校
 */
$(".reduceImg").click(function () {
    $(this).parent().remove();
});